package com.shop2cn.iapi.couponmanage.testcase.old;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.couponmanage.parameter.BatchInfo;
import com.shop2cn.iapi.couponmanage.parameter.BatchInfo4;
import com.shop2cn.iapi.couponmanage.parameter.CouponBag;
import com.shop2cn.iapi.couponmanage.parameter.CreateBagBean;
import com.shop2cn.iapi.couponmanage.parameter.CreateBean;
import com.shop2cn.iapi.couponmanage.parameter.GetBag;
import com.shop2cn.iapi.couponmanage.parameter.GetSubBatches;
import com.shop2cn.iapi.couponmanage.parameter.executeTaskBean;
import com.shop2cn.iapi.couponmanage.parameter.getSubBatchesBean;
import com.shop2cn.iapi.couponmanage.service.CreateBagCall;
import com.shop2cn.iapi.couponmanage.service.CreateCall;
import com.shop2cn.iapi.couponmanage.service.executeTaskCall;
import com.shop2cn.iapi.couponmanage.service.getSubBatchesCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponShop2cnMCallService;
import com.ymttest.database.model.couponbag;
import com.ymttest.database.model.couponbatch;
import com.ymttest.database.model.couponbatchext;
import com.ymttest.database.model.couponusecondition;
import com.ymttest.database.sqlwapper.couponbagWapper;
import com.ymttest.database.sqlwapper.couponbatchWapper;
import com.ymttest.database.sqlwapper.couponbatchextWapper;
import com.ymttest.database.sqlwapper.couponsendsubtaskWapper;
import com.ymttest.database.sqlwapper.couponuseconditionWapper;
/**
*获取套券中的子批次信息(支持批量)
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getSubBatches{
	private static getSubBatchesBean getsubbatchesBean;
	private static getSubBatchesCall getsubbatchesCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取套券中的子批次信息(支持批量)");
	}

	@Before
	public void caseUp() {
		getsubbatchesBean=new getSubBatchesBean();
		getsubbatchesCall=new getSubBatchesCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getsubbatchesCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_getSubBatches_001() {
		Logger.start(true,"获取套券中的子批次信息-套券中的子批次是随机兑换批次");
		try {
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponShop2cnMCallService.createPlatformCouponBag(createBagBean);

			//生成批次及兑换码
			List<String> bagCodes = new ArrayList<>();
			bagCodes.add(createBagCall.getbagCode());

			CreateBean createBean = CouponShop2cnMCallService.setDefaultRandomCreateBean(bagCodes);
			createBean.setBatchType(2);
			CreateCall createCall = CouponShop2cnMCallService.create(createBean);
		
			// 这里直接调用job接口生成兑换码
			List<Map>  tasks=new couponsendsubtaskWapper().selectTaskByTaskTypelimit(3,1);
			executeTaskCall call=new executeTaskCall();
			executeTaskBean bean=new executeTaskBean();
			
			for(int i=0;i<tasks.size();i++){
				bean.setSubTaskId(Integer.parseInt(tasks.get(i).get("SubTaskId").toString()));
				call.setData(bean);
				call.callService();
			}
			getsubbatchesBean.setBagCode(createBagCall.getbagCode());
			getsubbatchesCall.setData(getsubbatchesBean);
			getsubbatchesCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_getSubBatches_002() {
		Logger.start(true,"获取套券中的子批次信息-套券中的子批次是自定义兑换批次");
		try {
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponShop2cnMCallService.createPlatformCouponBag(createBagBean);

			//生成批次及兑换码
			List<String> bagCodes = new ArrayList<>();
			bagCodes.add(createBagCall.getbagCode());

			CreateBean createBean = CouponShop2cnMCallService.setDefaultCustomCreateBean(bagCodes);
			createBean.setBatchType(2);
			CreateCall createCall = CouponShop2cnMCallService.create(createBean);
		
			// 这里直接调用job接口生成兑换码
			List<Map>  tasks=new couponsendsubtaskWapper().selectTaskByTaskTypelimit(3,1);
			executeTaskCall call=new executeTaskCall();
			executeTaskBean bean=new executeTaskBean();
			for(int i=0;i<tasks.size();i++){
				bean.setSubTaskId(Integer.parseInt(tasks.get(i).get("SubTaskId").toString()));
				call.setData(bean);
				call.callService();
			}
			getsubbatchesBean.setBagCode(createBagCall.getbagCode());
			getsubbatchesCall.setData(getsubbatchesBean);
			getsubbatchesCall.callService();			
			verifyReturn();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_getSubBatches_003() {
		Logger.start(true,"获取套券中的子批次信息-套券没有子批次");
		try {
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			CreateBagCall createBagCall = CouponShop2cnMCallService.createPlatformCouponBag(createBagBean);
			
			getsubbatchesBean.setBagCode(createBagCall.getbagCode());
			getsubbatchesCall.setData(getsubbatchesBean);
			getsubbatchesCall.callService();			
			verifyReturn();		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_getSubBatches_004() {
		Logger.start(true,"获取套券中的子批次信息-bagCode=null");
		try {
			getsubbatchesBean.setBagCode(null);
			getsubbatchesCall.setData(getsubbatchesBean);
			getsubbatchesCall.callService();		
			verifyReturn();		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_getSubBatches_005() {
		Logger.start(true,"获取套券中的子批次信息-bagCodes为空字符串");
		try {
			getsubbatchesBean.setBagCode("");
			getsubbatchesCall.setData(getsubbatchesBean);
			getsubbatchesCall.callService();			
			verifyReturn();		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_getSubBatches_006() {
		Logger.start(true,"获取套券中的子批次信息-验证优惠券使用条件");
		try {
			CouponShop2cnMCallService CouponShop2cnMCallService = new CouponShop2cnMCallService();
			CreateBagBean createBagBean = CouponShop2cnMCallService.setDefaultPlatformCreateCouponBagBeanForRecieve();
			List<BatchInfo> BatchInfos=new ArrayList<BatchInfo>();
			BatchInfo info=new BatchInfo();
			info.setCouponName("自动化创建套券优惠券名称-子套券");
			info.setCouponDes("自动化创建套券优惠券描述-子套券");
			info.setApplyMemo("自动化创建申请理由-子套券");
			info.setOrderMinAmount(new BigDecimal(2));
			info.setDeductionMaxAmount(new BigDecimal(1));
			List<String> productIds = new ArrayList<String>();
			productIds.add("11");
			productIds.add("22");
			info.setProductIds(productIds);
			List<Integer> SellerIds = new ArrayList<Integer>();
			SellerIds.add(33);
			info.setSellerIds(SellerIds);
			List<Integer> ActivityIds = new ArrayList<Integer>();
			ActivityIds.add(44);
			info.setActivityIds(ActivityIds);
			List<Integer> Brands = new ArrayList<Integer>();
			Brands.add(55);
			info.setBrands(Brands);
			List<Integer> Countrys = new ArrayList<Integer>();
			Countrys.add(66);
			info.setCountrys(Countrys);
			List<Integer> Categories = new ArrayList<Integer>();
			Categories.add(77);
			info.setCategories(Categories);
			info.setLimitPspProduct(false);
			BatchInfos.add(info);
			createBagBean.setBatchInfos(BatchInfos);
			CreateBagCall createBagCall = CouponShop2cnMCallService.createPlatformCouponBag(createBagBean);

			getsubbatchesBean.setBagCode(createBagCall.getbagCode());
			getsubbatchesCall.setData(getsubbatchesBean);
			getsubbatchesCall.callService();			
			verifyReturn();		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	private void verifyReturn()
	{
		Logger.verifyEquals("0", getsubbatchesCall.getStatusCode1(), "验证返回code");
        Logger.verifyEquals("操作成功！", getsubbatchesCall.getMessage(), "验证返回Message");
        
        List<couponbatch> batchs=new couponbatchWapper().getCouponBatchByBagCode(getsubbatchesBean.getBagCode());
        GetSubBatches getSubBatches=getsubbatchesCall.getSubBatchesReturnData();
        List<BatchInfo4> bagInfos=getSubBatches.getBatchs();

        Logger.verifyEquals(batchs.size(), bagInfos.size(), "验证返回bags的条数与数据库couponbatch表中的套券总条数一致");

        for(int i=0;i<bagInfos.size();i++)
        {
    	 int count=+1;
   		 couponbatch bag=batchs.get(i);
   		 BatchInfo4 info=bagInfos.get(i);
   		 checkcouponbatch( bag, info, count);
		 checkcouponusecondition(bag.getBatchId(),info);
        }
	}
	
	private void checkcouponbatch(couponbatch bag,BatchInfo4 info,int count)
	{
		 Logger.comment("====方法：验证数据库couponbatch====");
		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		 
		 Logger.verifyEquals(bag.getBatchId(), info.getBatchId(), "验证返回第"+count+"条BatchId与数据库couponbatch表中的BatchId字段一致");
		 Logger.verifyEquals(bag.getBatchCode(), info.getBatchCode(), "验证返回第"+count+"条BatchCode与数据库couponbatch表中的BatchCode字段一致");
		 Logger.verifyEquals(bag.getCouponName(), info.getBatchName(), "验证返回第"+count+"条BatchName与数据库couponbatch表中的CouponName字段一致");
		 Logger.verifyEquals(bag.getSendType(), info.getSendType(), "验证返回第"+count+"条SendType与数据库couponbatch表中的SendType字段一致");
		 Logger.verifyEquals(bag.getEffectiveType(), info.getEffectiveType(), "验证返回第"+count+"条EffectiveType与数据库couponbatch表中的EffectiveType字段一致");
		 Logger.verifyEquals(bag.getEffectiveValidType(), info.getEffectiveValidType(), "验证返回第"+count+"条EffectiveValidType与数据库couponbatch表中的EffectiveValidType字段一致");
		 Logger.verifyEquals(bag.getValidStart(), info.getValidStart(), "验证返回第"+count+"条ValidStart与数据库couponbatch表中的ValidStart字段一致");
		 Logger.verifyEquals(bag.getValidEnd(), info.getValidEnd(), "验证返回第"+count+"条ValidEnd与数据库couponbatch表中的ValidEnd字段一致");
		 Logger.verifyEquals(bag.getEffectiveDays(), info.getEffectiveDays(), "验证返回第"+count+"条EffectiveDays与数据库couponbatch表中的EffectiveDays字段一致");
		 Logger.verifyEquals(bag.getTotalNum(), info.getTotalCount(), "验证返回第"+count+"条TotalCount与数据库couponbatch表中的TotalNum字段一致");
		 Logger.verifyEquals(bag.getReceivedCount(), info.getReceivedCount(), "验证返回第"+count+"条ReceivedCount与数据库couponbatch表中的ReceivedCount字段一致");
		 Logger.verifyEquals(bag.getReceiveUserType(), info.getUserType(), "验证返回第"+count+"条UserType与数据库couponbatch表中的ReceiveUserType字段一致");
		 Logger.verifyEquals(sdf.format(bag.getAcquireStartTime()), sdf.format(info.getAcquireStartTime()), "验证返回第"+count+"条AcquireStartTime与数据库couponbatch表中的AcquireStartTime字段一致");
		 Logger.verifyEquals(sdf.format(bag.getAcquireEndTime()), sdf.format(info.getAcquireEndTime()), "验证返回第"+count+"条acquireEndTime与数据库couponbatch表中的acquireEndTime字段一致");
		 Logger.verifyEquals(bag.getAcquireMethod(), info.getAcquireCouponMethod(), "验证返回第"+count+"条AcquireCouponMethod与数据库couponbatch表中的acquireMethod字段一致");
		 Logger.verifyEquals(bag.getReceiveTimesPerUser(), info.getAcquireQuantityPerUser(), "验证返回第"+count+"条AcquireQuantityPerUser与数据库couponbatch表中的ReceiveTimesPerUser字段一致");
		 Logger.verifyEquals(bag.getUseConditionType(), info.getProductLimitType(), "验证返回第"+count+"条ProductLimitType与数据库couponbatch表中的UseConditionType字段一致");
		 //batchStatus
		 Logger.verifyEquals(bag.getOperatorId(), info.getCreaterId(), "验证返回第"+count+"条CreaterId与数据库couponbatch表中的OperatorId字段一致");
		 Logger.verifyEquals(sdf.format(bag.getAddTime()), sdf.format(info.getCreateTime()), "验证返回第"+count+"条createTime与数据库couponbatch表中的AddTime字段一致");
		 
		 couponbatchext ext=new couponbatchextWapper().selectByPrimaryKey(bag.getBatchId());
		 Logger.verifyEquals(ext.getApplyUser(), info.getApplyUser(), "验证返回第"+count+"条ApplyUser与数据库couponbatch表中的ApplyUser字段一致");
		 Logger.verifyEquals(ext.getApplyMemo(), info.getApplyMemo(), "验证返回第"+count+"条ApplyMemo与数据库couponbatch表中的ApplyMemo字段一致");
		 Logger.verifyEquals(ext.getApplyDepartment(), info.getApplyDepartment(), "验证返回第"+count+"条ApplyDepartment与数据库couponbatch表中的ApplyDepartment字段一致");
		 Logger.verifyEquals(ext.getImpresetInvoiceId(), info.getImpresetInvoiceId(), "验证返回第"+count+"条ImpresetInvoiceId与数据库couponbatch表中的ImpresetInvoiceId字段一致");
		 //invalidUser
		 //invalidTime
		 //invalidMemo
		 Logger.verifyEquals(ext.getInvalidUser(), info.getInvalidUser(), "验证返回第"+count+"条InvalidUser与数据库couponbatch表中的InvalidUser字段一致");
		 Logger.verifyEquals(ext.getInvalidTime(), info.getInvalidTime(), "验证返回第"+count+"条InvalidTime与数据库couponbatch表中的InvalidTime字段一致");
		 Logger.verifyEquals(ext.getInvalidMemo(), info.getInvalidMemo(), "验证返回第"+count+"条InvalidMemo与数据库couponbatch表中的InvalidMemo字段一致");
		 
		 Logger.verifyEquals(bag.getCouponDes(), info.getBatchDes(), "验证返回第"+count+"条BatchDes与数据库couponbatch表中的CouponDes字段一致");
		 Logger.verifyEquals(bag.getCouponValue().stripTrailingZeros().toPlainString(), info.getCouponAmount().toString(), "验证返回第"+count+"条CouponAmount与数据库couponbatch表中的CouponValue字段一致");
		 Logger.verifyEquals(bag.getMinOrderValue().stripTrailingZeros().toPlainString(), info.getOrderMinAmount().toString(), "验证返回第"+count+"条OrderMinAmount与数据库couponbatch表中的MinOrderValue字段一致");

		
		 //单张优惠券限用次数
		 Logger.verifyEquals(bag.getReceiveTimesPerUser(), info.getUseNumPerCoupon(), "验证返回第"+count+"条ReceiveTimesPerUser与数据库couponbatch表中的UseNumPerCoupon字段一致");
		 //本批次最大使用次数
		 Logger.verifyEquals(bag.getTotalNum(), info.getUseTotalCount(), "验证返回第"+count+"条UsedCount与数据库couponbatch表中的UseTotalCount字段一致");
		 Logger.verifyEquals(bag.getUsedCount(), info.getUsedCount(), "验证返回第"+count+"条UsedCount与数据库couponbatch表中的UsedCount字段一致");
		 Logger.verifyEquals(sdf.format(bag.getExpiredDate()), sdf.format(info.getExpiredDate()), "验证返回第"+count+"条ExpiredDate与数据库couponbatch表中的ExpiredDate字段一致");
		 //优惠券类型 couponType
		 int countType=bag.getAcquireMethod()!=3?1:2;
		 Logger.verifyEquals((byte)countType, info.getCouponType(), "验证返回第"+count+"条CouponType与数据库couponbatch表中的CouponType字段一致");
		 Logger.verifyEquals(bag.getCreaterType(), info.getBatchCreateType(), "验证返回第"+count+"条CouponType与数据库couponbatch表中的CreaterType字段一致");
		 Logger.verifyEquals(bag.getIsShowInPage(), info.showInPage(), "验证返回第"+count+"条CouponType与数据库couponbatch表中的CreaterType字段一致");
		 //
		 boolean receiveOver=bag.getReceivedCount()==bag.getTotalNum()?true:false;
		 Logger.verifyEquals(receiveOver, info.getReceiveOver(), "验证返回第"+count+"条receiveOver与数据库couponbatch表中的ReceivedCount字段一致");
		 //cancellation
		 Logger.verifyEquals(bag.getIsShowInPage(), info.showInPage(), "验证返回第"+count+"条CouponType与数据库couponbatch表中的CreaterType字段一致");
		 //expire 是否过期
		 Date dNow = new Date(); // 当前时间
        Calendar calendar1 = Calendar.getInstance(); // 得到日历
        calendar1.setTime(dNow);// 把当前时间赋给日历
        calendar1.add(Calendar.DAY_OF_MONTH, 0); 
        dNow = calendar1.getTime(); 
		 Date expDate=bag.getExpiredDate();
		 int num = expDate.compareTo(dNow); 
		 boolean d=num>=0?false:true;
		 Logger.verifyEquals(d, info.getIsExpire(), "验证返回第"+count+"条IsExpire与数据库couponbatch表中的IsExpire字段一致");
		 //isCancellation
		 Logger.verifyEquals(bag.getIsInvalid(), info.getCancellation(), "验证返回第"+count+"条Cancellation与数据库couponbatch表中的IsInvalid字段一致");
		 Logger.verifyEquals(bag.getIsInvalid(), info.getCancellation(), "验证返回第"+count+"条Cancellation与数据库couponbatch表中的IsInvalid字段一致");
		 //isExpire
		 //isReceiveOver
		 //isShowInPage
	}
	
	/**
	 * 
	 * @param batchId
	 * @param item 数据库查询couponbatch
	 * @param batchInfo call返回的batchInfo
	 */
	 private void checkcouponusecondition(int batchId,BatchInfo4 callbatchInfo)
	    {
	    	Logger.comment("====方法：验证数据库checkcouponusecondition====");
	    	List<couponusecondition> couponuseconditions=new couponuseconditionWapper().selectByBatchId(batchId);
	    	couponbatch couponbatch= new couponbatchWapper().selectByPrimaryKey(batchId);
	    	if(couponuseconditions.size()==0)
	    	{
				Logger.verifyEquals(0, couponbatch.getUseConditionType(),
	                    "验证限制类型为通用时 数据库couponbatch表中UseConditionType=0");
	    	}
	           //0:通用 1:指定买手，2：指定商品，3：指定活动，4：指定分类，5：指定国家，6：指定品牌，7：指定国家和分类，8：仅优先商品
	    	//国家和分类
			if(callbatchInfo.getCountrys().isEmpty()==false && callbatchInfo.getProductCategories().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> clist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,5);
				List<couponusecondition> pclist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,4);
				String cstr="";
				String pcstr="";
				for(int i=0;i<clist.size();i++)
				{
				  cstr+=clist.get(i).getConditionValue()+",";	  
				}
				for(int i=0;i<pclist.size();i++)
				{
					pcstr+=pclist.get(i).getConditionValue()+",";	  
				}
				cstr=cstr.substring(0, cstr.length()-1);
				pcstr=pcstr.substring(0, pcstr.length()-1);
				 Logger.verifyEquals(callbatchInfo.getCountrys(), cstr, "验证限制类型为指定国家和分类时 返回 Countrys");
				 Logger.verifyEquals(callbatchInfo.getProductCategories(), pcstr, "验证限制类型为指定国家和分类时 返回 ProductCategories");
			    Logger.verifyEquals(7, couponbatch.getUseConditionType(), "验证限制类型为指定国家和分类时 数据库couponbatch表中UseConditionType=7");
			    Logger.verifyEquals(7, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
			    return;
			}
			//指定买手
			if(callbatchInfo.getSellerIds().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,1);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getSellerIds(), str.substring(0, str.length()-1),
	                      "验证限制类型为指定买手时 返回SellIds");
    			Logger.verifyEquals(1, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//商品
			if(callbatchInfo.getSpecificProducts().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,2);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getSpecificProducts(), str.substring(0, str.length()-1),"验证限制类型为指定商品时 返回SpecificProducts");
    			Logger.verifyEquals(2, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			
			//分类
			if(callbatchInfo.getActivityIds().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,3);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getActivityIds(), str.substring(0, str.length()-1),"验证限制类型为活动时 返回ActivityIds");
    			Logger.verifyEquals(3, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//活动
			if(callbatchInfo.getProductCategories().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,4);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getProductCategories(), str.substring(0, str.length()-1),"验证限制类型为活动时 返回ProductCategories");
    			Logger.verifyEquals(4, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//国家
			if(callbatchInfo.getCountrys().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,5);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getCountrys(), str.substring(0, str.length()-1),"验证限制类型为国家时 返回Countrys");
    			Logger.verifyEquals(5, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//品牌
			if(callbatchInfo.getProductBrands().isEmpty()==false && couponuseconditions.size()!=0)
			{
				List<couponusecondition> cslist=new couponuseconditionWapper().selectByConditionTypeAndBatchId(batchId,6);
				String str="";
				for(int j=0;j<cslist.size();j++){
					
					str+=cslist.get(j).getConditionValue()+",";
				}
    			Logger.verifyEquals(callbatchInfo.getProductBrands(), str.substring(0, str.length()-1),"验证限制类型为国家时 返回ProductBrands");
    			Logger.verifyEquals(6, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
			//优先商品
			if(callbatchInfo.getProductLimitType()==8 &&  couponuseconditions.size()!=0)
			{
				Logger.verifyEquals(8, couponbatch.getUseConditionType(),
	                    "验证限制类型为指定优先商品时 数据库couponbatch表中UseConditionType");
				Logger.verifyEquals(8, couponbatch.getUseConditionType(),
	                    "验证限制类型为优选商品时 数据库couponbatch表中UseConditionType=8");
				Logger.verifyEquals(8, callbatchInfo.getProductLimitType(), "验证返回的ProductLimitType");
				return;
			}
	    }
}